﻿using IGolovkine.ShoutCastRipper.Testing.ConnectionRecorder;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Xml;
using IGolovkine.Core;
using IGolovkine.ShoutCastRipper;
using System.Text;
using System.IO;
using IGolovkine.Core.Testing;
using System;

namespace ShoutCastRipper.Testing.ConnectionRecorder.UnitTests
{
    [TestClass]
    public class XmlStationClientEventWriterTest
    {

        private XmlStationClientEventWriter _writer;
        private StringBuilder _buffer;

        [TestInitialize]
        public void MyTestInitialize()
        {
            _buffer = new StringBuilder();
            _writer = new XmlStationClientEventWriter(() => new XmlTextWriter(new StringWriter(_buffer)));
        }
        

        [TestMethod]
        public void ReadWriteAcidTest()
        {
            _writer.WriteContentStartEvent(new ContentStartEventArgs(Tester.GenerateUniqueString()));
            _writer.WriteContentReceivedEvent(new ContentReceivedEventArgs(Tester.GenerateUniqueData(), Tester.GenerateUniqueString(), TimeSpan.FromSeconds(1)));
            _writer.WriteContentEndEvent(new ContentEndEventArgs(Tester.GenerateUniqueString(), TimeSpan.FromSeconds(1)));
            _writer.WriteDisconnectedEvent(new DisconnectedEventArgs(Tester.GenerateUniqueString(), TimeSpan.FromSeconds(1)));
            _writer.WriteDisconnectedEvent(new DisconnectedEventArgs(Tester.GenerateUniqueString(), TimeSpan.FromSeconds(1), new ArgumentException("Hello")));
            _writer.Dispose();
        }
    }
}
